package com.zyd.shiro.persistence.dao;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

import com.zyd.shiro.persistence.beans.Order;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * 数据访问接口
 * @author Administrator
 *
 */
public interface MallOrderDao extends JpaRepository<Order,Integer>,JpaSpecificationExecutor<Order>{

    @Query(value = "select * from mall_order  where user_id = ?1",nativeQuery = true)
    public List<Order> getAllByUser_id(Integer userId);


    @Query(value = "select * from mall_order  where delivery_status = ?1 AND pay_status = ?2",nativeQuery = true)
    public List<Order> getAllByDelivery_status(Integer status,Integer payStatus);

    @Query(value = "select * from mall_order  where receipt_status = ?1 AND delivery_status = ?2",nativeQuery = true)
    public List<Order> getAllByReceipt_statusAAndDelivery_status(Integer status,Integer deliveryStatus);

    @Query(value = "select * from mall_order where pay_status = ?1",nativeQuery = true)
    public List<Order> getAllByPay_status(Integer status);


    @Query(value = "select * from  mall_order  where pay_status = ?1 and delivery_status = ?2 and receipt_status = ?3",nativeQuery = true)
    public List<Order> getAllByPay_statusAndDelivery_statusAndReceipt_status(Integer payStatus,Integer deliveryStatus,Integer ReceiptStatus);

    @Query(value = "select * from mall_order where order_status = ?1",nativeQuery = true)
    public List<Order> getAllByOrder_status(Integer status);

}
